<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.commons.SessionKeys,
                 com.scalar.chiptrack.users.Functionality,
                 com.scalar.chiptrack.operations.packingslip.forms.SendMailForm,
                 com.scalar.chiptrack.utils.StringUtils" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<%
    String closeWindowAfterSessionTimeOut = ( String ) request.getAttribute( "closeWindowAfterSessionExp" );
    String  vendorMailAttachmentType = (String) request.getAttribute("vendorMailAttachmentType");
    if ( closeWindowAfterSessionTimeOut == null && vendorMailAttachmentType == null )
    {
%>
    <chiptrack:checkLogon sourcePage="/sendMail.do"/>
<%  } %>

<html:html>

<HEAD><TITLE>ChipTrac - Send Email</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<%
    String customerShippingId = ( String ) request.getAttribute( "customerShippingId" );
    String salesOrderId = ( String ) request.getAttribute( "salesOrderId" );
    String locationId   = ( String ) request.getAttribute("locationId");
    String fromUser = null;
    SendMailForm sendMailForm = null;
    User user = null;
    if ( closeWindowAfterSessionTimeOut == null )
    {
        user = ( User ) session.getAttribute( SessionKeys.USER_KEY );
        fromUser = user.getEmail();

        sendMailForm = ( SendMailForm ) request.getAttribute( "sendMailForm" );
        if( sendMailForm == null ) sendMailForm = new SendMailForm();
    }

    String vendorSubjectText =  ( String ) request.getAttribute("vendorSubjectText");
    String customerSubjectText =  ( String ) request.getAttribute("customerSubjectText");

    String psEmails = ( String )request.getAttribute( "psEmails" );
    String commEmails = ( String )request.getAttribute( "commEmails" );
    String vendorEmail = ( String )request.getAttribute( "vendorEmail" );
    String userMails = ( String )request.getAttribute( "userMails" );

    psEmails    = ( psEmails    == null ? "":psEmails);
    commEmails  = ( commEmails  == null ? "":commEmails);
    vendorEmail = ( vendorEmail == null ? "":vendorEmail);
    userMails   = ( userMails   == null ? "":userMails);

    String toUserEmails =  psEmails + "," + commEmails + ", " + userMails ;
    try
    {
        if( ( userMails != null ) && userMails.length() > 0 )
        {
            if( ( vendorEmail == null || "".equalsIgnoreCase( vendorEmail ) ) && ( vendorEmail.length() == 0 ) )
            {
                vendorEmail = userMails;
            }
            else
            {
                vendorEmail = vendorEmail + ", " + userMails;
            }

            if( ( psEmails == null || "".equalsIgnoreCase( psEmails ) ) && ( psEmails.length() == 0 ))
            {
                psEmails = userMails ;
            }
            else
            {
                psEmails = psEmails + ", " + userMails ;
            }
        }
    }
    catch( Exception e )
    {
      e.printStackTrace();
    }
%>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</SCRIPT>


<style>
<!--
a.nav:link   { font-family: Verdana,Arial,San Serif; font-size: 10px; text-decoration: underline }
a.nav:visited { font-family: Verdana,Arial,San Serif; font-size: 10px; text-decoration: none }
a.nav:active { font-family: Verdana,Arial,San Serif; font-size: 10px; text-decoration: underline }
a.nav:hover  { font-family: Verdana,Arial,San Serif; font-size: 10px; text-decoration: none; color: red }
.HEADING     { cursor: hand; font-family: Verdana,Arial,San Serif; font-size: 11px; color: blue;
               font-weight: none;
               border: 1 solid #000000 }
.LINKSOFF    { display: none; font-family: Verdana,Arial,San Serif; font-size: 12px; color: #000000; }
.LINKSON     { display: inline; font-family: Verdana,Arial,San Serif; font-size: 12px; color: #000000; }
-->
</style>

<Script Language="VBscript">
// Copyright 2001 Stephen Hayes (steve@obtsolutions.co.uk)
// OBT Solutions UK (http://www.obtsolutions.co.uk)
// Permission granted to SimplytheBest.net to feature script in its
// DHTML script collection at http://simplythebest.net/info/dhtml_scripts.html
<!--
Option Explicit
DIM menuID,menuObj,cellBk
SUB ShowHide(menuID)
menuObj = "Link" & menuID
cellbk = "Head" & menuID
// CHECK IF OPEN
if document.all.item(menuObj).className = "LINKSON" then    'IF MENU OPEN THEN CLOSE
document.all.item(menuObj).className = "LINKSOFF"
document.all.item(cellBk).style.backgroundColor = "#FFFFFF"   ' SET CELL BACKGROUND COLOUR BLUE
ELSE
document.all.item(menuObj).className = "LINKSON"               ' OPEN MENU
document.all.item(cellBk).style.backgroundColor = "#FFFFFF"  ' SET CELL BACKGROUND COLOUR RED
END IF
END SUB
-->
</Script>


<script language='javascript'>

var defaultCustomerEmails = "";
var defaultVendorEmails   = "";
var defaultCustomerPsEmails = "";

<% if ( toUserEmails != null && toUserEmails.trim().length() > 0 ) { %>
    defaultCustomerEmails = '<%=StringUtils.removeDuplicateEmailIds(toUserEmails)%>';
<% }
  if ( vendorEmail != null && vendorEmail.trim().length() > 0 ) { %>
    defaultVendorEmails = '<%=StringUtils.removeDuplicateEmailIds(vendorEmail)%>';
<% }
  if ( psEmails != null && psEmails.trim().length() > 0 ) { %>
    defaultCustomerPsEmails = '<%=StringUtils.removeDuplicateEmailIds(psEmails)%>';
<% } %>

function loadEmailIds(optionBoxValue)
{
    var emailIdsString = "";
    var subjectString  = "";
    if ( optionBoxValue == "customer" && defaultCustomerPsEmails != "" )
    {
        //alert( "defaultCustomerPsEmails = " + defaultCustomerPsEmails )
        emailIdsString = defaultCustomerPsEmails;
    }
    else if ( optionBoxValue == "vendor" && defaultVendorEmails != "" )
    {
        //alert( "defaultVendorEmails = " + defaultVendorEmails )
        emailIdsString = defaultVendorEmails;
    }

    if ( optionBoxValue == "customer" )
    {
        subjectString = '<%=customerSubjectText%>';
    }
    else if ( optionBoxValue == "vendor" )
    {
        subjectString = '<%=vendorSubjectText%>';
    }
    document.sendMailForm.subject.value = subjectString;

    //if ( emailIdsString != "" )
    //{
        if(typeof document.sendMailForm.toUsers.length == "undefined" )
	    {
            document.sendMailForm.toUsers.value    =  emailIdsString;
        }
        else
        {
            document.sendMailForm.toUsers[0].value =  emailIdsString;
        }

    //}
}

function validateTo()
{
    var checkCount = 0;


    if( ( document.sendMailForm.toUsers.selectedIndex != null ) && ( document.sendMailForm.toUsers.selectedIndex < 0 ) )
    {
        document.sendMailForm.txtErrMsg.value = 'To cannot be blank';
        return false;
    }

    if(document.sendMailForm.toUsers.length == null )
	{

            if( document.sendMailForm.toUsers.value == "" )
            {
                document.sendMailForm.txtErrMsg.value = 'To cannot be blank';
                document.sendMailForm.toUsers.focus();
                return false;
            }
            if(isValidMailID(document.sendMailForm.toUsers.value,"To","Y")==false)
            {
                 document.sendMailForm.txtErrMsg.value=errMsg;
                 document.sendMailForm.toUsers.value = "";
                 document.sendMailForm.toUsers.focus();
                 return false;
            }
            else
            {
                document.sendMailForm.txtErrMsg.value="";
                return true;
            }
    }
    else
    {

        if( ( document.sendMailForm.toUsers.selectedIndex != null ) && ( document.sendMailForm.toUsers.selectedIndex >= 0 ) )
        {
            document.sendMailForm.txtErrMsg.value="";
            return true;
        }

        var nullEmailCount = 0;
        for ( var i=0; i < document.sendMailForm.toUsers.length; i++ )
        {
            if( document.sendMailForm.toUsers[i].value.length == 0 )
            {
                nullEmailCount++;
            }
        }

        if( nullEmailCount == document.sendMailForm.toUsers.length )
        {
            document.sendMailForm.txtErrMsg.value = 'To cannot be blank';
            return false;
        }

        for ( var i=0; i < document.sendMailForm.toUsers.length; i++ )
        {
            if(isValidMailID(document.sendMailForm.toUsers[i].value,"To","N")==false)
            {
                 document.sendMailForm.txtErrMsg.value=errMsg;
                 document.sendMailForm.toUsers[i].value = "";
                 document.sendMailForm.toUsers[i].focus();
                 return false;
            }
            else
            {
                checkCount++;
            }

        }
        if ( parseInt(checkCount) > 0 )
        {
            document.sendMailForm.txtErrMsg.value="";
            return true;
        }
        else
        {
            return false;
        }
    }
    return true;
}
function validateCC()
{
    var checkCount=0;
    if ( document.sendMailForm.ccUsers.length == null )
    {
            if(isValidMailID(document.sendMailForm.ccUsers.value,"CC","N")==false)
            {
                 document.sendMailForm.txtErrMsg.value=errMsg;
                 document.sendMailForm.ccUsers.value = "";
                 document.sendMailForm.ccUsers.focus();
                 return false;
            }
            else
            {
                document.sendMailForm.txtErrMsg.value="";
                return true;
            }
    }
    else
    {
        for ( var i=0; i < document.sendMailForm.ccUsers.length; i++ )
        {
            if(isValidMailID(document.sendMailForm.ccUsers[i].value,"CC ","N")==false)
            {
                 document.sendMailForm.txtErrMsg.value=errMsg;
                 document.sendMailForm.ccUsers[i].value = "";
                 document.sendMailForm.ccUsers[i].focus();
                 return false;
            }
            else
            {
                checkCount++;
            }
        }
    }
    if ( parseInt(checkCount) == parseInt(document.sendMailForm.ccUsers.length) )
    {
        document.sendMailForm.txtErrMsg.value="";
        return true;
    }
    else
    {
        return false;
    }
}
function validateBCC()
{
var checkCount=0;
    if ( document.sendMailForm.bccUsers.length == null )
    {
            if(isValidMailID(document.sendMailForm.bccUsers.value,"BCC","N")==false)
            {
                 document.sendMailForm.txtErrMsg.value=errMsg;
                 document.sendMailForm.bccUsers.value = "";
                 document.sendMailForm.bccUsers.focus();
                 return false;
            }
            else
            {
                document.sendMailForm.txtErrMsg.value="";
                return true;
            }

    }
    else
    {
        for ( var i=0; i < document.sendMailForm.bccUsers.length; i++ )
        {
            if(isValidMailID(document.sendMailForm.bccUsers[i].value,"BCC","N")==false)
            {
                 document.sendMailForm.txtErrMsg.value=errMsg;
                 document.sendMailForm.bccUsers[i].value = "";
                 document.sendMailForm.bccUsers[i].focus();
                 return false;
            }
            else
            {
                checkCount++;
            }
        }
        if ( parseInt(checkCount) == parseInt(document.sendMailForm.bccUsers.length) )
        {
            document.sendMailForm.txtErrMsg.value="";
            return true;
        }
        else
        {
            return false;
        }
    }

}
function validateSubject()
{
    if(alphanumSpecialChar(document.sendMailForm.subject.value,"Subject","N")==false)
    {
         document.sendMailForm.txtErrMsg.value=errMsg;
         document.sendMailForm.subject.focus();
         return false;
     }
     else
     {
        return true;
     }
}
function validateMessage()
{
    if( parseInt(document.sendMailForm.message.value.length) > 1000 )
    {
         document.sendMailForm.txtErrMsg.value="Message should not contain more than 1000 cahracters";
         document.sendMailForm.message.focus();
         return false;
     }
     else
     {
        return true;
     }
}
// Added by Krishn Prasad on 24 June 2004 , because Select Box is replaced by Text BOx
function chkBlankEmail()
{
    //alert(document.sendMailForm.toUsers.length);
    if(typeof document.sendMailForm.toUsers.length == 'undefined' )
    {
        if( document.sendMailForm.toUsers.value == "" )
        {
            document.sendMailForm.txtErrMsg.value = 'To cannot be blank';
            document.sendMailForm.toUsers.focus();
            return false;
        }
    }
    /*else
    {
        var chkNull = 0;
        for( var xx = 0 ; xx < document.sendMailForm.toUsers.length ; xx++ )
        {
            if(document.sendMailForm.toUsers[xx].value != "")
            {
                chkNull++;
            }
        }
        if( chkNull == 0 )
        {
            document.sendMailForm.txtErrMsg.value = 'To cannot be blank';
            document.sendMailForm.toUsers.focus();
            return false;
        }
    } */
    return true;
}

function sendMail()
{
    var flag=false;
    document.sendMailForm.customerShippingId.value = "<%=customerShippingId%>" ;

    //Commented by Krishna on 18 May 2004
    /*if ( ( validateTo() == true ) && (validateCC()==true) && (validateBCC()==true) && ( validateSubject() == true ) && ( validateMessage() == true )  )
    {
        document.sendMailForm.submit();
        //window.close();
    } */
    //Added by varma 01 Sep 2004 to restrict the mails which are in hide state
    if( document.getElementById('link0').className == 'LINKSOFF')
    {
        document.sendMailForm.ccUsers.value = '';
        for ( var i=0; i < document.sendMailForm.ccUsers.length; i++ )
        {
            document.sendMailForm.ccUsers[i].value = '';
        }
    }
    if( document.getElementById('link1').className == 'LINKSOFF')
    {
        document.sendMailForm.bccUsers.value = '';
        for ( var i=0; i < document.sendMailForm.bccUsers.length; i++ )
        {
            document.sendMailForm.bccUsers[i].value = '';
        }
    }//till here
    // Added by Krishna Prasad on 18 May 2004
    if ( ( chkBlankEmail() == true ) &&  ( validateMultipleEmail()==true ) && ( validateSubject() == true ) && ( validateMessage() == true ))
    {
        if(typeof document.sendMailForm.toUsers.length == 'undefined' )
        {
            document.sendMailForm.toUsers.disabled=false;
        }
        else
        {
            document.sendMailForm.toUsers[0].disabled=false;
        }
        document.sendMailForm.submit();
    }
}

var emailCount = 0;
var OnlyOneflag=false;  // Added by Krishna Prasad 18 May 2004
function newEmail( fieldName, fieldLabel, fontId, colorCode ) {

    /*
    //Starts Here Added by Krishna Prasad 18 May 2004
    var clickHereStr="";
    var chkIsConfirmFlagFromActionClass=false;

    <logic:present name="isConfirm">
        chkIsConfirmFlagFromActionClass=true;
    </logic:present>

    if(( OnlyOneflag==false ) && ( fieldName=="toUsers" ) && ( chkIsConfirmFlagFromActionClass == false ))
    {
       OnlyOneflag=true;
       clickHereStr=clickHereStr + ' <font class="NArialL">Please ';
       clickHereStr=clickHereStr + ' <a styleClass="leftsection" href="javascript:showContactPersonMailIds(<%=salesOrderId%>, <%=customerShippingId%>)"';
       clickHereStr=clickHereStr + ' onmouseover="window.status=\'Click to show Contact Person MailIds\';return true" onmouseout="window.status=\'\';return true">click here</a>';
       clickHereStr=clickHereStr + ' to select MailIds</font>';
       //alert("ddd " + clickHereStr );
    }
    else
    {
       clickHereStr="";
    }
    // Ends Here Added by Krishna Prasad 18 May 2004
    */

    //modified by Krishna Prasad 18 May 2004, 'Click Here' Link added
    //var htmltext1 = '<table cellspacing=0 cellpadding=0 border="0" width="100%"><tr><td width="15%"><font class="NArialL" ><font color="' + colorCode + '">' + fieldLabel + ':</font></font></td><td width="85%"><input type="text" name="' + fieldName + '" size="40" maxlength="100" class="txfield">'+clickHereStr+'</td></tr></table>';
    var htmltext1 = '<table cellspacing=0 cellpadding=0 border="0" width="100%"><tr><td width="15%"><font class="NArialL" ><font color="' + colorCode + '">' + fieldLabel + ':</font></font></td><td width="85%"><input type="text" name="' + fieldName + '" size="40" maxlength="100" class="txfield"></td></tr></table>';
    var pa1 = document.getElementById (fontId);
    emailCount = emailCount + 1;

    if( emailCount == 8 )
    {
        window.resizeTo( 800, 700 );
    }

    pa1.insertAdjacentHTML ('BeforeEnd',htmltext1);

}

function editCommercialInvoice( salesOrderId, customerShippingId, locationId )
{
    var invoiceURL = '<%=chipTracContext%>/commercialInvoice.do?action=loadInvoice&salesOrderId=' + salesOrderId + '&customerShippingId=' + customerShippingId + '&fromEmailPS=yes' + '&locationId=' + locationId;
    newWindow = window.open (invoiceURL,'editCommercialInvoice','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,resizable=yes');
    newWindow.focus();
}

function showCC()
{

}

function showBCC()
{

}

//This function Added by Krishna Prasad on 18 May 2004
var errMsgL="";
function commaEmailValidate(emailsSeperateWithCommas)
{
    errMsgL="";
    errMsg="";
	var emailAry = emailsSeperateWithCommas.split(",");
	for(var x=0;x<emailAry.length;x++)
	{
        var str=emailAry[x].replace(/^\s+/,'').replace(/\s+$/,'');
        if( str.length > 0 )
        {
            errMsg="";
         <%--   ValidateMail(str);
			chkBlankSpaces1(str);
			checkemail(str);
			if(errMsg!="")
			{
				errMsgL=errMsgL + str + " , ";
			} --%>
            if( !ValidEMail(str) )  <%--modified by varma (15jun2004) to restict the mails like xxx@xx...xx --%>
            {
                 errMsgL=errMsgL + str + " , ";
            }
        }
	}
    if( errMsgL == "")
    {
	    return true;
    }
    else
    {
        if( errMsgL.length > 2 )
        {
            errMsgL=errMsgL.substring(0,errMsgL.length-2);
        }
        return false;
    }
}

//This function Added by Krishna Prasad on 18 May 2004
function validateMultipleEmail()
{
    document.sendMailForm.txtErrMsg.value="";
    var noSelectedItem=false;
    var countNullTo=0;
    for( var x = 0 ; x < document.sendMailForm.elements.length ; x++ )
    {
       var tmpElement = document.sendMailForm.elements[x];
       //alert(" Element Name : " + tmpElement.name + " Type :" + tmpElement.type + " Value :" + tmpElement.value);
       if( tmpElement.type == "select-multiple" )
       {
            if(( tmpElement.name == "toUsers" ) || ( tmpElement.name == "ccUsers" ) || ( tmpElement.name == "bccUsers"  ))
            {
                if(( tmpElement.selectedIndex == -1 ))
                {
                    //alert("empty");
                }
                else
                {
                    if(commaEmailValidate(tmpElement.value)==false)
					{
						document.sendMailForm.txtErrMsg.value="Enter valid email address : " + errMsgL;
						tmpElement.focus();
                        return false;
					}
                }
             }
       }

       if( tmpElement.type == "text")
       {
            if(( tmpElement.name == "toUsers" ) || ( tmpElement.name == "ccUsers" ) || ( tmpElement.name == "bccUsers"  ))
            {
                if( typeof tmpElement.length == 'undefined' )
                {
                    if(commaEmailValidate(tmpElement.value)==false)
					{
						document.sendMailForm.txtErrMsg.value="Enter valid email address : " + errMsgL;
						tmpElement.focus();
                        return false;
					}
                }
                else
                {
                    for( var xx = 0 ; xx < tmpElement.length ; xx++ )
                    {
                        //alert("dd " + commaEmailValidate(tmpElement[xx].value) );
                        if(commaEmailValidate(tmpElement[xx].value)==false)
                        {
                            document.sendMailForm.txtErrMsg.value="Enter valid email address : " + errMsgL;
                            tmpElement[xx].focus();
                            return false;
                        }
                    }
                }
             }
       }
    }
    if ( document.sendMailForm.toUsers.length != null )
    {
        //alert("ddd ");
        var nullEmailCount = 0;

        if(( document.sendMailForm.toUsers.selectedIndex != null ) && ( document.sendMailForm.toUsers.selectedIndex < 0 ) )
        {
            document.sendMailForm.txtErrMsg.value = 'To cannot be blank';
            return false;
        }

        for ( var i=0; i < document.sendMailForm.toUsers.length; i++ )
        {
            if( document.sendMailForm.toUsers[i].value.length == 0 )
            {
                nullEmailCount++;
            }
        }
        //alert(nullEmailCount + " = " + document.sendMailForm.toUsers.length );

        if( nullEmailCount == document.sendMailForm.toUsers.length )
        {
            document.sendMailForm.txtErrMsg.value = 'To cannot be blank';
            return false;
        }
     }
    return true;
}

//This function Added by Krishna Prasad on 18 May 2004
function showContactPersonMailIds( salesOrderId, customerShippingId )
{
    var recipientType = 'customer';
    for( var i=0 ; i < document.sendMailForm.recipientType.length; i++ )
    {
       if( document.sendMailForm.recipientType[i].value == "vendor")
       {
           if( document.sendMailForm.recipientType[i].checked )
           {
                recipientType = 'vendor';
           }
       }
    }
    <% if( vendorMailAttachmentType != null ) { %>
        newWindowPs = window.open ('sendMail.do?action=showPSContactPersonDetails&salesOrderId='+salesOrderId+'&recipientType='+recipientType+'&customerShippingId='+ customerShippingId + '&vendorMailAttachmentType=<%=vendorMailAttachmentType%>','psContactEmailsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=500,resizable=no');
    <% } else { %>
        newWindowPs = window.open ('sendMail.do?action=showPSContactPersonDetails&salesOrderId='+salesOrderId+'&recipientType='+recipientType+'&customerShippingId='+ customerShippingId,'psContactEmailsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=500,resizable=no');
    <% } %>
    newWindowPs.focus();
}
//added by varma 20 jul 2004 to add commercial Invoice Mails
function loadCommInvoiceMails()
 {
    /*if(document.sendMailForm.sendCommercialInvoice.checked == true )
    {
    //document.sendMailForm.action.value = "loadCommInvoiceMails";
    //document.sendMailForm.submit();
    }
    else
    {
      tolength =  document.sendMailForm.toUsers.length
	  if( typeof tolength != "undefined" )
	  {
		document.sendMailForm.toUsers[tolength-1].value = "";
	  }
      else
      {
        //document.sendMailForm.toUsers.value = "";
      }
    }*/
    var emailIdsString = "";
    var flag = false;
    for( var i=0 ; i < document.sendMailForm.recipientType.length; i++ )
    {
       if( document.sendMailForm.recipientType[i].value == "vendor")
       {
           if( document.sendMailForm.recipientType[i].checked )
           {
                flag = true;
           }
       }
    }

    if ( document.sendMailForm.sendCommercialInvoice.checked == true && defaultCustomerEmails != ""  && !flag )
    {
        emailIdsString = defaultCustomerEmails;
    }
    else if ( document.sendMailForm.sendCommercialInvoice.checked == false && defaultCustomerPsEmails != "" && !flag )
    {
        emailIdsString = defaultCustomerPsEmails;
    }
        if(typeof document.sendMailForm.toUsers.length == "undefined" )
	    {
            document.sendMailForm.toUsers.value    = emailIdsString;
        }
        else
        {
            document.sendMailForm.toUsers[0].value = emailIdsString;
        }
 }

function setDefaultOption()
{
    var chkIsConfirmFlagFromActionClass = false;
    var vendorMailAttachmentType        = "";
    <% if( vendorMailAttachmentType != null ) { %>
        vendorMailAttachmentType        = '<%=vendorMailAttachmentType%>';
    <% } %>
    <logic:present name="isConfirm">
        chkIsConfirmFlagFromActionClass=true;
    </logic:present>


    if(typeof document.sendMailForm != "undefined" && document.sendMailForm.dropShippment.value == "true" && document.sendMailForm.status.value == "ISSUED" && chkIsConfirmFlagFromActionClass != true )
    {
        for( var i=0 ; i < document.sendMailForm.recipientType.length; i++ )
        {
           if( document.sendMailForm.recipientType[i].value == "vendor")
           {
               document.sendMailForm.recipientType[i].checked = true;
               loadEmailIds('vendor');
           }
        }
    }
    if(typeof document.sendMailForm != "undefined" && chkIsConfirmFlagFromActionClass != true &&  vendorMailAttachmentType != "" )
    {
       if( vendorMailAttachmentType == "ShipmentPickNotice")
       {
           document.sendMailForm.recipientType[1].checked = true;
           loadEmailIds('vendor');
       }
       else
       {
           document.sendMailForm.recipientType[0].checked = true;
           loadEmailIds('customer');
       }
    }
}

</script>
</HEAD>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0" onLoad="javascript:setDefaultOption();">
<%
if ( closeWindowAfterSessionTimeOut == null )
{
%>

<html:form name="sendMailForm" type="com.scalar.chiptrack.operations.packingslip.forms.SendMailForm" action="/sendMail.do">
<table bgcolor='#FFFFFF' border='0' cellpadding='0' cellspacing='0' width='100%' bordercolor='#993333'>
<tr><td>
<table cellpadding='0' cellspacing='0' bgcolor='FDF5E6' border="0" width="100%" align=center>

    <tr><td valign=center colspan='2' bgcolor="#993333" align='center'><font class='NArialW'><font color='#FFFFFF'><img height=20 width='28' src="<%=chipTracContext%>/jsp/includes/images/email_icon.jpg">&nbsp;Packing Slip and Commercial Invoice Mail</font></font></td></tr>

    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td><chiptrack:info styleClass="NArialL"/></td>
    </tr>

    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td ><chiptrack:errors styleClass="NArialL"/></td>
    </tr>

    <tr>
        <td colspan='2' align='right' valign=center>
        <a href="javascript:window.close();" title='Click here to close this window' onMouseOver="window.status='Click here to close this window';return true"><font class='NArialL'><b>[Close this window]</b></font></a>&nbsp;&nbsp;&nbsp;&nbsp;
        </td>
    </tr>
    <tr><td colspan='2'><img height=5 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr>
    <tr align="right"> <%--This tr tag added by Krishna Prasad on 18 May 2004--%>
        <td width="50%"><font class="NArialL" >&nbsp;</font></td>
        <td align="right">
            <table cellpadding='0' cellspacing='0' border='0' width='100%' class='NArialL'>
                <tr>
                    <td width="50%"><font color='#003333'>&nbsp;</font></td>
                    <td width="50%">
                    <font class='NArialS'><font color='orange'><li> Type Email Address, separated by commas. <li>To send Packing Slip to other Emails that are not present in the system, click on <b>[+]</b> </font></font>
                    </td>
            </table>
        </td>
    </tr>
    <tr>
    <td width="20%"><font class="NArialL" >&nbsp;</font></td>
    <td  bgcolor='#FDF5E6'><INPUT align="left" border="0" maxLength=100 name="txtErrMsg" size="100"  style="BACKGROUND-COLOR:#FDF5E6; BORDER-BOTTOM: thin; BORDER-LEFT-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP: thin; CLEAR: none; COLOR: red;font-family: arial;font-size: 10pt;font-weight:bold " value="" readOnly></td></tr>
    <tr><td colspan='2'><img height=5 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr>
    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td >
            <table cellpadding='0' cellspacing='0' border='0' width='100%' class='NArialL'>
                <tr>
                    <td>
                        <table cellpadding='0' cellspacing='0' border='0' width='100%' class='NArialL'>
                            <tr>
                                <td width="15%"><font color='#003333'>From:</font></td>
                                <td width="85%"><bean:write name='sendMailForm' property='fromUser'/><%--<%=fromUser%>--%></td>
                                <html:hidden property="fromUser"/>
                            </tr>
                            <tr>
                                <td width="15%">&nbsp;</td>
                                <td width="85%">
                                    <font class="NArialL">Please
                                        <a styleClass="leftsection" href="javascript:showContactPersonMailIds(<%=salesOrderId%>, <%=customerShippingId%>)"
                                        onmouseover="window.status='Click to show Contact Person MailIds';return true"
                                        onmouseout="window.status='';return true">click here</a> to select MailIds
                                    </font>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr><td colspan='2'><img height=5 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr>
    <!-- DISPLAY "TO" VALUES - START - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <tr>
        <td width="20%">&nbsp;</td>
        <td >

            <table cellpadding='0' cellspacing='0' border='0' width='100%' class='NArialL'>
                <%
                    boolean addto = false;
                    String[] toUsers = sendMailForm.getToUsers();
                    if( ( toUsers == null ) || ( toUsers.length == 0 ) )
                    {
                %>
                    <tr>
                        <td width="15%" class='NArialL'>
                            <font color='#990000'>TO:</font>
                            <br><br><a ID='head0' CLASS="HEADING" ONCLICK='ShowHide(0)'><font class='NArialS'>[Show CC]</font></a>
                            <br><a ID='head1' CLASS="HEADING" ONCLICK='ShowHide(1)'><font class='NArialS'>[Show BCC]</font></a>
                        </td>
                        <td width='50%'>
                            <% if( vendorMailAttachmentType != null && vendorMailAttachmentType.equalsIgnoreCase("packingslip") ) { %>
                                <input type="text" name="toUsers" size="40" class="txfield" value="<%=psEmails%>" disabled="true">
                            <% } else { %>
                                <input type="text" name="toUsers" size="40" class="txfield" value="<%=psEmails%>" >
                            <% } %>
                            <%--<input type="text" name="toUsers" size="40" class="txfield" value="<%=psEmails%>" >--%>
                            <a href="javascript:newEmail( 'toUsers', 'TO', 'font1', '#990000' )" title='Click to add other Emails'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align=center></a>
                        </td>
                        <td width='35%' align='left'>&nbsp;</td>
                    </tr>
                <%  }
                    else
                    {
                        int count = 0;
                        for( int i=0; i<toUsers.length; i++ )
                        {
                            if( ( toUsers[i] != null ) && ( toUsers[i].trim().length() != 0 ) )
                            { count++;
                %>
                            <tr>
                                <td width="15%">
                                    <font class="NArialL" ><font color='#990000'>TO:</font></font>
                                    <%
                                    if( !addto )
                                    {
                                    %>
                                    <br><br><a ID='head0' CLASS="HEADING" ONCLICK='ShowHide(0)'><font class='NArialS'>[Show CC]</font></a>
                                    <br><a ID='head1' CLASS="HEADING" ONCLICK='ShowHide(1)'><font class='NArialS'>[Show BCC]</font></a>
                                    <%
                                    }
                                    %>
                                </td>
                                <td width='85%'>
                                    <% if( vendorMailAttachmentType != null && vendorMailAttachmentType.equalsIgnoreCase("packingslip") ) { %>
                                        <input type="text" name="toUsers" value='<%=toUsers[i]%>' size="40"  class="txfield" disabled="true">
                                     <% } else { %>
                                        <input type="text" name="toUsers" value='<%=toUsers[i]%>' size="40"  class="txfield">
                                    <% } %>
                                    <%--<input type="text" name="toUsers" value='<%=toUsers[i]%>' size="40"  class="txfield">--%>
                        <%
                        if( !addto )
                        {
                            addto = true;
                        %>
                            <font class='NArialS'><b><a href="javascript:newEmail( 'toUsers', 'TO', 'font1', '#990000' )" title='Click to add other Emails'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align=center></a></b></font>
                        <%
                        }
                        %>
                            </td>
                        </tr>
                        <%
                            }
                        }
                        %>
                        <tr>
                            <td width="15%" class='NArialL'>
                                <% if( count == 0 ) { %>
                                    <br><br><a ID='head0' CLASS="HEADING" ONCLICK='ShowHide(0)'><font class='NArialS'>[Show CC]</font></a>
                                    <br><a ID='head1' CLASS="HEADING" ONCLICK='ShowHide(1)'><font class='NArialS'>[Show BCC]</font></a>
                                <% } %>
                             </td>
                            <td width='50%'>
                                <% if( count == 0 ) { %>
                                    <a href="javascript:newEmail( 'toUsers', 'TO', 'font1', '#990000' )" title='Click to add other Emails'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align=center></a>
                                <% } %>
                            </td>
                            <td width='35%' align='left'>&nbsp;</td>
                        </tr>
                        <%
                    }
                %>
            </table>
        </td>
    </tr>
    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td ><font id="font1"></font></td>
    </tr>
    <!-- DISPLAY "TO" VALUES - END - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<tr>
<td colspan='2'>
<%-- Added by Krishna Prasad on 18 May 2004--%>
<%
    boolean addcc = false;
    String[] ccUsers = sendMailForm.getCcUsers();
    if(ccUsers==null || ccUsers.length == 0)
    {
%>
<div ID='link0' CLASS="LINKSOFF">
<%
    }
    else
    {
%>
<div ID='link0'>
<%
    }
%>
    <table cellpadding='0' cellspacing='0' border='0' width='100%' style="BORDER-BOTTOM: thin; BORDER-LEFT-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP: thin; CLEAR: none;" >
    <tr><td colspan='2'><font class="NArialL" >&nbsp;</font></td></tr>
    <!-- DISPLAY "CC" VALUES - START - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <tr>
        <td><font class="NArialL" >&nbsp;</font></td>
        <td >
            <table cellpadding='0' cellspacing='0' border='0' width='100%' class='NArialL'>
                <%
                    if( ( ccUsers == null ) || ( ccUsers.length == 0 ) )
                    {
                %>
                    <tr>
                        <td width="15%">
                            <font color='#660033'>CC:</font>
                            <br><br><a CLASS="HEADING" ONCLICK='ShowHide(0)'><font class='NArialS'>[Hide CC]</font></a>
                        </td>
                        <td width='85%' valign=center>

                            <input type="text" name="ccUsers" size="40" maxlength='100' class="txfield">
                            <font class='NArialS'><b><a href="javascript:newEmail('ccUsers', 'CC', 'font2', '660033')"  title='Click to add other Emails'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align=center></a></b></font>
                        </td>
                    </tr>
                <%  }
                    else
                    {
                        for( int i=0; i<ccUsers.length; i++ )
                        {
                            if( ( ccUsers[i] != null) && ( ccUsers[i].trim().length() > 0 ) )
                            {
                %>
                            <tr>
                                <td width="15%">
                                    <font class="NArialL"><font color='#660033'>CC:</font></font>
                                    <% //Added by Krishna Prasad on 18 May 2004
                                    if( !addcc )
                                    {
                                    %>
                                    <br><br><a CLASS="HEADING" ONCLICK='ShowHide(0)'><font class='NArialS'>[Hide CC]</font></a>
                                    <%
                                    }
                                    %>
                                </td>
                                <td width='85%'><input type="text" name="ccUsers" value='<%=ccUsers[i]%>' size="40" maxlength='100' class="txfield">
                <%
                        if( !addcc )
                        {
                            addcc = true;
                %>
                            <font class='NArialS'><b><a href="javascript:newEmail('ccUsers', 'CC', 'font2', '#660033')"  title='Click to add other Emails'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align=center></a></b></font>
                <%
                        }
                %>
                    </td></tr>
                <%
                            }
                        }
                    }
                %>
            </table>
        </td>
    </tr>
    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td ><font id="font2"></font></td>
    </tr>
</table>
</div>
</td>
</tr>
    <!-- DISPLAY "CC" VALUES - END - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<tr>
<td colspan='2'>
<%
    boolean addbcc = false;
    String[] bccUsers = sendMailForm.getBccUsers();
    if(bccUsers == null || bccUsers.length == 0)
    {
%>
<div ID='link1' CLASS="LINKSOFF">
<%
    }
    else
    {
%>
<div ID='link1' >
<%
    }
%>
    <table cellpadding='0' cellspacing='0' border='0' width='100%' style="BORDER-BOTTOM: thin; BORDER-LEFT-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP: thin; CLEAR: none;" >
    <tr><td colspan='2'><font class="NArialL" >&nbsp;</font></td></tr>
    <!-- DISPLAY "BCC" VALUES - START - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td >

            <table cellpadding='0' cellspacing='0' border='0' width='100%' class='NArialL'>
                <%
                    if( ( bccUsers == null ) || ( bccUsers.length == 0 ) )
                    {
                %>

                    <tr>
                        <td width="15%">
                            <font color='#003333'>BCC:</font>
                            <br><br><a CLASS="HEADING" ONCLICK='ShowHide(1)'><font class='NArialS'>[Hide BCC]</font></a>
                        </td>
                        <td width='85%'>
                           <input type="text" name="bccUsers" size="40" maxlength='100' class="txfield">
                           <font class='NArialS'><b><a href="javascript:newEmail('bccUsers', 'BCC', 'font3', '#003333')"  title='Click to add other Emails'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align=center></a></b></font>
                        </td>
                    </tr>
                <%  }
                    else
                    {
                        for( int i=0; i<bccUsers.length; i++ )
                        {
                            if( ( bccUsers[i] != null ) && ( bccUsers[i].trim().length() != 0 ) )
                            {
                %>
                            <tr>
                                <td width="15%">
                                    <font class="NArialL"><font color='#003333'>BCC:</font></font>
                                    <% //Added by Krishna Prasad on 18 May 2004
                                    if( !addbcc )
                                    {
                                    %>
                                    <br><br><a CLASS="HEADING" ONCLICK='ShowHide(1)'><font class='NArialS'>[Hide BCC]</font></a>
                                    <%
                                    }
                                    %>
                                </td>
                                <td width='85%'><input type="text" name="bccUsers" value='<%=bccUsers[i]%>' size="40" maxlength='100' class="txfield">
                <%
                        if( !addbcc )
                        {
                            addbcc = true;
                %>
                            <font class='NArialS'><b><a href="javascript:newEmail('bccUsers', 'BCC', 'font3', '#003333')"  title='Click to add other Emails'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align=center></a></b></font>
                <%
                        }
                %>
                    </td></tr>
                <%
                            }
                        }
                    }
                %>
            </table>
        </td>
    </tr>
    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td ><font id="font3"></font></td>
    </tr>
</table>
</div>
</td></tr>
    <!-- DISPLAY "BCC" VALUES - END - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <tr><td colspan='2'><font class="NArialL" >&nbsp;</font></td></tr>
    <tr><td colspan='2'><img height=5 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr>
    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td >
            <table cellpadding='0' cellspacing='0' border='0' width='100%' class='NArialL'>
                <tr>
                    <td width="15%" nowrap>Recipient Type</td>
                    <td width='85%'>
                        <% if(  vendorMailAttachmentType == null ) { %>
                            <% if( sendMailForm.isDropShippment() && sendMailForm.getPackingSlipStatus().equalsIgnoreCase("issued") ) { %>
                                <html:radio name='sendMailForm' property='recipientType' value="customer" onclick="loadEmailIds('customer');" disabled="true"/>Customer &nbsp;&nbsp;
                                <html:radio name='sendMailForm' property='recipientType' value="vendor" onclick="loadEmailIds('vendor');" />Vendor
                             <% } else { %>
                                <html:radio name='sendMailForm' property='recipientType' value="customer" onclick="loadEmailIds('customer');"/>Customer &nbsp;&nbsp;
                                <html:radio name='sendMailForm' property='recipientType' value="vendor" onclick="loadEmailIds('vendor');"/>Vendor
                            <% } %>
                       <% } else { %>
                            <% if( vendorMailAttachmentType.equalsIgnoreCase("shipmentpicknotice") ) { %>
                                <html:radio name='sendMailForm' property='recipientType' value="customer" onclick="loadEmailIds('customer');" disabled="true"/>Customer &nbsp;&nbsp;
                                <html:radio name='sendMailForm' property='recipientType' value="vendor" onclick="loadEmailIds('vendor');" />Vendor
                            <% } else { %>
                                <html:radio name='sendMailForm' property='recipientType' value="customer" onclick="loadEmailIds('customer');"/>Customer &nbsp;&nbsp;
                                <html:radio name='sendMailForm' property='recipientType' value="vendor" onclick="loadEmailIds('vendor');"  disabled="true"/>Vendor
                            <% } %>
                        <% } %>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" width="100%">&nbsp;</td>
                </tr>
                <tr>
                    <td width="15%"><font class="NArialL" ><font color='#003333'>Subject:</font></font></td>
                    <td width='85%'><html:text name='sendMailForm' property='subject' size='40' maxlength='200' styleClass='txfield'/></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr><td colspan='2'><img height=15 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr>
    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td ><font class="NArialL" >Message:</font></td>
    </tr>
    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td>
            <html:textarea cols="70" rows="5" name='sendMailForm' property='message'  styleClass='txfield'/>
            <input type="hidden" name='action' value='save'>
            <input type="hidden" name='customerShippingId' value='<%=customerShippingId%>'>
            <input type="hidden" name='salesOrderId' value='<%=salesOrderId%>'>
            <input type="hidden" name='status' value='<bean:write name="sendMailForm" property="packingSlipStatus" />' >
            <input type="hidden" name='dropShippment' value='<bean:write name="sendMailForm" property="dropShippment" />'>
        </td>
    </tr>
    <tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td>
            <font class='NArialL'>

                <% if( vendorMailAttachmentType != null && vendorMailAttachmentType.equalsIgnoreCase("shipmentpicknotice") ) { %>
                    <html:checkbox name='sendMailForm' property='sendCommercialInvoice' disabled="true"/>
                 <% } else { %>                    
                    <html:checkbox name='sendMailForm' property='sendCommercialInvoice'/>
                <% } %>
                &nbsp;&nbsp;Attach Commercial Invoice&nbsp;&nbsp;&nbsp;&nbsp;
                <!- changed by hareesh on 3rd September 2003, Since once Shipped don't allow user to edit commercial Invoice -->
                <logic:notEqual name='sendMailForm' property='packingSlipStatus' value='SHIPPED'>
                    <logic:notEqual name='sendMailForm' property='packingSlipStatus' value='CANCELLED'>
                        <% if ( user.isActionAllowed ( Functionality.COMMERCIAL_INVOICE,    User.USER_ACTION_VIEW ) ) { %>
                            <a href="javascript:editCommercialInvoice( '<%=salesOrderId%>', '<%=customerShippingId%>', '<%=locationId%>' )" class='NArialL'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/edit_icon_small1.jpg' height='20' width='19' align=center>Edit Commercial Invoice</a>
                        <% } %>
                    </logic:notEqual>
                </logic:notEqual>

            </font>
        </td>
    </tr>
   <tr>
        <td width="20%"><font class="NArialL" >&nbsp;</font></td>
        <td>
            <font class='NArialL'>
               Attach as
               <% if( vendorMailAttachmentType != null ) { %>
                    <input type="hidden" name="vendorMailAttachmentType" value='<%=vendorMailAttachmentType%>'>
                    <html:radio name='sendMailForm' property='attachMIMEType' value="HTML" disabled="true" />
               <% } else { %>
                    <html:radio name='sendMailForm' property='attachMIMEType' value="HTML" />
               <% } %>
               &nbsp;&nbsp; HTML Format&nbsp;&nbsp;
               <html:radio name='sendMailForm' property='attachMIMEType' value="PDF" />&nbsp;&nbsp;Adobe PDF Version&nbsp;&nbsp;
            </font>
        </td>
    </tr>
    <tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
    <tr><td colspan='2' align=center>
    <logic:notEqual name="isConfirm" value="True" >
        <a href="javascript:sendMail()">
            <img onMouseOver="window.status='Click here send a mail';return true"  border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17"></a>
    </logic:notEqual>
    <logic:equal name="isConfirm" value="True">
        <a href="javascript:sendMail()">
            <img onMouseOver="window.status='Click here send a mail';return true"  border="0" src="<%=chipTracContext%>/jsp/includes/images/confirm.gif"></a>
    </logic:equal>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <a href="javascript:window.close();"><img onMouseOver="window.status='Click here to close this window';return true"  border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width="53" height="17"></a>
    </td></tr>
    <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr><td colspan='2'><br><br><br><br><br><br><br><br><br><br><br><br></td></tr>
</table>
</td></tr>
</table>
</html:form>
<% } else { %>
    <table cellpadding='0' cellspacing='0' bgcolor='FDF5E6' border="0" width="100%"  height="100%" align=center>
        <tr>
            <td>
                <table align="center" border="0" width="40%" bgcolor="#FDF5E6">
                    <tr><td>&nbsp;</td></tr>
                    <tr><td align="center" ><font class="NArialL" ><font color="red">Session has been time out , Please close this window and login again.</font></font></td></tr>
                    <tr><td>&nbsp;</td></tr>
                    <tr><td align="center" ><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></td></tr>
                </table>
            </td>
       </tr>
       <tr><td>&nbsp;</td></tr>
    </table>
<% } %>
</BODY>
</html:html>